//
//  ViewController.swift
//  YDOAProduct
//
//  Created by YDWY on 2017/5/17.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit
import DPToastView
import Toaster
import Popover_OC

class ViewController: UIViewController {

    var array : Array<PopoverAction>?
    

    
    override func viewDidLoad() {
        super.viewDidLoad()
        (DPToastView.makeToast("我只是刚启动的时候显示一下而已", gravity: DPToastGravityBottom, duration: 40.0) as? DPToastView)?.show()
        Toast.init(text: "我只是刚启动的时候显示一下而已", delay: 0, duration: 40.0).show()
           YMNetworkManager.shareInstance.getRequest(urlString: "http://peixun.xgyuanda.com/appc/category_index.html?token=sxyapp&u_id=32", params: nil, success: { (response) in

            YMLog.log(item:response)
            
           }) { (error) in
            
        }
        
        setupUI()
        
        // Do any additional setup after loading the view, typically from a nib.
    }
    @IBAction func sender1(_ sender: UIButton) {
       let popView =  PopoverView()
        popView.show(to: sender, with:setActions())
        
    }

    @IBAction func sender2(_ sender: Any) {
        
        
    }
    @IBAction func sender3(_ sender: Any) {
        
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}


extension ViewController {
    
    fileprivate func setupUI(){
        
        
    }
    fileprivate func getData(){
        
        
        
    }
    
    
    //返回点击视图
    fileprivate func setActions() -> [PopoverAction] {
        //发起多人聊天
        let  multichatAction =   PopoverAction(title: "发起多人聊天") { (result) in
            YMLog.log(item: result?.title ?? "获取失败")
        }
        //加好友
        let addFriAction =  PopoverAction(title: "加好友") { (result) in
            YMLog.log(item: result?.title ?? "获取失败")
        }
        
        //扫一扫 action
        let QRAction =  PopoverAction(title: "扫一扫") { (result) in
            YMLog.log(item: result?.title ?? "获取失败")
        }
        
        //面对面快传
        let facetofaceAction =  PopoverAction(title: "面对面快传") { (result) in
            YMLog.log(item: result?.title ?? "获取失败")
        }
        
        //付款
        let payMoneyAction =  PopoverAction(title: "付款") { (result) in
            YMLog.log(item: result?.title ?? "获取失败")
        }
        array = [multichatAction!, addFriAction!, QRAction!, facetofaceAction!, payMoneyAction!]
        
        return [multichatAction!, addFriAction!, QRAction!, facetofaceAction!, payMoneyAction!]

    }
    
    
    
}


